Skip to content

Fix mobile auth reliability#25

Merged
prazgaitis merged 1 commit intomainfrom
fix/mobile-auth-reliability
Feb 13, 2026
Merged

Fix mobile auth reliability#25
prazgaitis merged 1 commit intomainfrom
fix/mobile-auth-reliability

Conversation

@prazgaitis
Copy link
Copy Markdown
Owner

Summary

  • Disable refetchOnWindowFocus in Better Auth client — on mobile, switching apps or pulling down the notification shade triggers visibilitychange, causing /get-session round-trips that temporarily clear auth state and flicker data
  • Enable server-side session cookieCache (5 min TTL) — avoids a DB lookup on every /get-session call, speeding up auth bootstrap on slow mobile connections
  • Add www variant to CORS allowedOrigins in http.ts — was already present in trustedOrigins in auth.ts but missing from the HTTP router CORS config, causing silent CORS failures for www. visitors
  • Add error logging to silent catch blocksgetCurrentUser() and getServerAuth() were swallowing auth errors with empty catches, making mobile failures invisible in production logs

Test plan

  • Verify auth works on mobile Safari (sign in, navigate between pages, switch away from app and return)
  • Check that session persists across tab focus changes without flickering
  • Verify Google OAuth flow still works on mobile
  • Check Vercel logs for any [auth] or [server-auth] error messages that were previously hidden

🤖 Generated with Claude Code

… cache, fix CORS

- Disable refetchOnWindowFocus in Better Auth client to prevent mobile
  tab-switch visibility changes from clearing auth state mid-session
- Enable server-side session cookieCache (5 min TTL) to avoid DB lookups
  on every /get-session call, speeding up auth bootstrap on slow connections
- Add www variant to CORS allowedOrigins in http.ts to match trustedOrigins
  in auth.ts — prevents CORS failures when accessing via www subdomain
- Add console.error logging to silent catch blocks in getCurrentUser and
  getServerAuth so auth failures are visible in production logs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
march-fitness-2025 Building Building Preview, Comment Feb 13, 2026 3:20pm

Request Review

@prazgaitis prazgaitis merged commit c543c32 into main Feb 13, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant